<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/category.png'); ?>"> Menu Items Edit</h1>

        <div class="buttons">
            <a class="button" href="#" onClick="$('#menu_items_edit').submit()"><span>Save</span></a>
        </div>
    </div>
    <div class="content">

        <?php echo form_open(null, 'id="menu_items_edit"') ?>
        <div id="tabs">
            <ul class="htabs">
                <li><a href="#item-tab">Menu Item</a></li>
              
            </ul>
            <div id="item-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required">*</span> Link Type:', 'type')?>
                        <?php echo form_dropdown('page_type', array('page'=>'Page', 'url'=>'URL'), set_value('page_type',!empty($itemdetails['page_type']) ? $itemdetails['page_type'] : ''), 'id="page_type"')?>
                    </div>
                    <div class="page_div">
                        <?php echo form_label('<span class="required">*</span> Pages:', 'entry_id')?>
							<select value="" name="page_id" id="page_id">
							<?php 
								foreach($pages as $page)
								{
									if($page['pageid']==$itemdetails['pageid'])
									{
										echo "<option title='".$page['title']."' url=".$page['url']." value='".$page['pageid']."' selected='selected'>".$page['title']."</option>";
									}
									else
									{
										echo "<option title='".$page['title']."' url=".$page['url']." value='".$page['pageid']."'>".$page['title']."</option>";
									}
								}	
							?>
							</select>
							<input type="hidden" name="pagetitle" id="pagetitle" value="" /> 
							<input type="hidden" name="pageurl" id="pageurl" value="" /> 
					</div>
                    
                    <div class="url_div">
                        <?php echo form_label('<span class="required">*</span> Link Text:', 'title')?>
                        <?php echo form_input(array('name'=>'title', 'id'=>'title', 'class'=>'long', 'value'=>set_value('title',!empty($itemdetails['title']) ? $itemdetails['title'] : '')))?>
                    </div>
                    <div class="url_div">
                        <?php echo form_label('<span class="required">*</span> URL:', 'url')?>
                        <?php echo form_input(array('name'=>'url', 'id'=>'url', 'class'=>'long','value'=>set_value('url',!empty($itemdetails['url']) ? $itemdetails['url'] : '')))?>
                    </div>
                    <div>
                        <?php echo form_label('Target:', 'target')?>
                        <?php echo form_dropdown('target', array(''=>'Current Window', '_blank'=>'New Tab / Window (_blank)'), set_value('target',!empty($itemdetails['target']) ? $itemdetails['target'] : ''), 'id="target"')?>
                    </div>
                    <div>
                        <?php echo form_label('Class:', 'class')?>
                        <?php echo form_input(array('name'=>'class', 'id'=>'class', 'class'=>'long', 'value'=>set_value('class',!empty($itemdetails['class']) ? $itemdetails['class'] : '')))?>
                    </div>
                </div>
            </div>
            
        </div>
        <?php echo form_close() ?>
    </div>
</div>


<script type="text/javascript">
    $(document).ready(function() {

        $('#page_type').change(function() {
		
            if ($(this).val() == 'page')
            {
                $('.url_div').hide();    
                $('.page_div').show();    
            }
            else
            {
                $('.page_div').hide();    
                $('.url_div').show();    
            }
        });

        $('#page_type').trigger('change');
		$('#page_id').change(function() {
			$("#pagetitle").val($("#page_id option:selected").attr('title'));
		
			$("#pageurl").val($("#page_id option:selected").attr('url'));
		});
		$('#page_id').trigger('change');
        $( "#tabs" ).tabs();

    });
</script>
